<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS计算器（02）</title>
    <script>
        function calc() {
            var input01 = prompt("请输入第一个操作数：", "7");
            var oper = prompt("请输入操作符：(仅支持：+ - * /)", "+");
            var input02 = prompt("请输入第二个操作数：", "3");
            num01 = parseFloat(input01);
            num02 = parseFloat(input02);
            var rst = calc02(num01, oper, num02);

            alert("运算结果为：" + rst);
        }

        function calc02(n1, op, n2) {
            var result;
            switch (op) {
                case"+":
                    result = n1 + n2;
                    break;
                case"-":
                    result = n1 - n2;
                    break;
                case"*":
                    result = n1 * n2;
                    break;
                case"/":
                    result = n1 / n2;
                    break;
                default:
                    result = "你大爷的，计算器都不会用吗，啊！！！";
                    break;
            }
            return result;
        }
    </script>
</head>
<body>
<div align="center">
    <input name="cale" type="button" value="JS计算器（02）" onclick="calc();"/>
</div>
</body>
</html>